home *** CD-ROM | disk | FTP | other *** search
- Path: news.microsoft.com!news
- From: a-cnadc@microsoft.com (Dann Corbit)
- Newsgroups: comp.lang.c
- Subject: Re: Q: free() function
- Date: 8 Apr 1996 23:01:50 GMT
- Organization: Microsoft Corporation
- Message-ID: <4kc5su$u9c@news.microsoft.com>
- References: <4k9ai7$rck@tibalt.supernet.ab.ca>
- NNTP-Posting-Host: 157.57.171.202
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.93.14
-
- In article <4k9ai7$rck@tibalt.supernet.ab.ca>, lts@news.supernet.ab.ca says...
- >
- >When dynamically allocating memory for a series of strings and storing
- >the addresses in a char pointer array, can all the allocated memory be
- >freed simply using "free(array)" or does "free(array[x])" have to be
- >executed for each pointer in the array.
- >
- >I think the latter would be correct but I'm not 100% sure, please comment.
- >
- >-lts
- Depends on how the allocation was performed. If calloc() was used, one
- free() statment will do it. If malloc() was repeatedly called, you need
- one free() for each malloc(). Also if the array itsself were allocated
- this will require a call to free() also.
- --
- The opinions expressed in this message are my own personal views
- and do not reflect the official views of Microsoft Corporation.
- In fact, I'm just a subcontractor, not an employee, so pull in your claws.
-
-